﻿using System.Drawing;

namespace TimedTextLibrary
{
    public static class Extentions
    {
        public static void SetProperties<T>(this T source, T target)
        {
            foreach (var prop in typeof(T).GetProperties())
            {
                var valueToSet = prop.GetGetMethod().Invoke(source, null);
                if (valueToSet != null)
                    prop.GetSetMethod().Invoke(target, new[] { valueToSet });
            }
        }

        public static Color ToColor(this System.Windows.Media.Color mediaColor)
        {
            var color = FromHtml(mediaColor); //Color.FromArgb(mediaColor.R, mediaColor.G, mediaColor.B);

            return color;
        }

        public static Color FromHtml(this System.Windows.Media.Color color)
        {
            return ColorTranslator.FromHtml(color.ToString());
        }
    }
}